package com.lingyuan.controller;

import com.lingyuan.common.core.domain.R;
import com.lingyuan.common.core.domain.vo.pms.SearchResult;
import com.lingyuan.common.core.domain.vo.pms.SkuAttrVo;
import com.lingyuan.service.SearchsService;
import org.elasticsearch.search.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName SearchController
 * @Description 描述
 * @Author guoxin
 * @Date 2024/9/21 12:09
 */
@RestController
@RequestMapping("/es")
public class SearchController {
    @Autowired
    private SearchsService searchService;
    /**
     * 功能:批量添加
     */
    @PostMapping("/bulkAdd")
    public R bulkAdd(@RequestBody List<SkuAttrVo> skuAttrVos){
        searchService.bulkAdd(skuAttrVos);
        return R.ok("批量添加成功");
    }
    /**
     * 功能:商品多条件搜索
     */
    @PostMapping("/search")
    public R search(){
        SearchResult searchResult = searchService.search();
        return R.ok(searchResult);
    }
    /**
     * 功能: 删除商品
     */
    @DeleteMapping("/del/{spuId}")
    public R del(@PathVariable("spuId") Long spuId){
        searchService.del(spuId);
        return R.ok("删除成功");
    }
}
